package com.code.zjm.demo.ui;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;

/**
 * Created by ZJM on 2017/3/3.
 */
public class AtyShowRadioGroup extends AppCompatActivity {
    private Button ensureChosen;
    private RadioGroup rdGroup;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_radio_group);
        ensureChosen = (Button) findViewById(R.id.ensureChosen);
        rdGroup = (RadioGroup) findViewById(R.id.rdGroup);
        ensureChosen.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                RadioButton crtRadioBtn = (RadioButton) findViewById(rdGroup.getCheckedRadioButtonId());
                //简易弹框
                new AlertDialog.Builder(AtyShowRadioGroup.this).setTitle("提示")
                        .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.cancel();
                            }
                        }).setMessage(crtRadioBtn.getText()).show();
            }
        });
    }
}
